<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>DJI 无人机监控系统</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css" />
    <style>
        body {
            padding-top: 20px;
        }
        #map {
            height: 500px;
            width: 100%;
            border-radius: 5px;
        }
        .drone-card {
            margin-bottom: 15px;
            cursor: pointer;
            transition: transform 0.2s;
        }
        .drone-card:hover {
            transform: translateY(-5px);
        }
        .status-badge {
            font-size: 0.8rem;
            padding: 5px 10px;
        }
        .battery-indicator {
            height: 20px;
            border-radius: 3px;
            overflow: hidden;
        }
        .mission-panel {
            margin-top: 20px;
            display: none;
        }
        .waypoint-list {
            max-height: 200px;
            overflow-y: auto;
        }
    </style>
</head>
<body>
    <div class="container">
        <header class="mb-4">
            <h1 class="text-center">DJI 无人机监控系统</h1>
            <p class="text-center text-muted">实时监控和控制您的大疆无人机</p>
        </header>
        
        <div class="row">
            <!-- 左侧无人机列表 -->
            <div class="col-md-3">
                <div class="card">
                    <div class="card-header bg-primary text-white">
                        <h5 class="mb-0">无人机列表</h5>
                    </div>
                    <div class="card-body p-0">
                        <div id="droneList" class="list-group list-group-flush">
                            <!-- 无人机列表将通过JavaScript动态加载 -->
                        </div>
                    </div>
                </div>
                
                <!-- 无人机控制面板 -->
                <div id="droneControlPanel" class="card mt-3" style="display: none;">
                    <div class="card-header bg-success text-white">
                        <h5 class="mb-0">无人机控制</h5>
                    </div>
                    <div class="card-body">
                        <div id="droneControls">
                            <button id="takeoffBtn" class="btn btn-success btn-sm mb-2 w-100">起飞</button>
                            <button id="landBtn" class="btn btn-warning btn-sm mb-2 w-100">降落</button>
                            <button id="returnBtn" class="btn btn-info btn-sm mb-2 w-100">返航</button>
                            <button id="hoverBtn" class="btn btn-secondary btn-sm mb-2 w-100">悬停</button>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- 中间地图区域 -->
            <div class="col-md-6">
                <div class="card">
                    <div class="card-header bg-primary text-white">
                        <h5 class="mb-0">实时地图</h5>
                    </div>
                    <div class="card-body p-0">
                        <div id="map"></div>
                    </div>
                </div>
            </div>
            
            <!-- 右侧信息面板 -->
            <div class="col-md-3">
                <!-- 无人机详情面板 -->
                <div id="droneInfoPanel" class="card">
                    <div class="card-header bg-primary text-white">
                        <h5 class="mb-0">无人机信息</h5>
                    </div>
                    <div class="card-body">
                        <div id="droneInfo">
                            <p class="text-center text-muted">选择一架无人机查看详情</p>
                        </div>
                    </div>
                </div>
                
                <!-- 任务规划面板 -->
                <div id="missionPanel" class="card mission-panel">
                    <div class="card-header bg-primary text-white">
                        <h5 class="mb-0">任务规划</h5>
                    </div>
                    <div class="card-body">
                        <div id="missionInfo">
                            <button id="createMissionBtn" class="btn btn-primary btn-sm mb-2 w-100">创建新任务</button>
                            <button id="viewMissionsBtn" class="btn btn-info btn-sm mb-2 w-100">查看任务列表</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 创建任务模态框 -->
        <div class="modal fade" id="createMissionModal" tabindex="-1" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title">创建飞行任务</h5>
                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                    </div>
                    <div class="modal-body">
                        <form id="missionForm">
                            <div class="mb-3">
                                <label for="missionName" class="form-label">任务名称</label>
                                <input type="text" class="form-control" id="missionName" required>
                            </div>
                            <div class="mb-3">
                                <label class="form-label">航点列表</label>
                                <div id="waypointsList" class="waypoint-list">
                                    <p class="text-muted">在地图上点击添加航点</p>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                        <button type="button" class="btn btn-primary" id="saveMissionBtn">保存任务</button>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 任务列表模态框 -->
        <div class="modal fade" id="missionsListModal" tabindex="-1" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title">飞行任务列表</h5>
                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                    </div>
                    <div class="modal-body">
                        <div id="missionsList">
                            <!-- 任务列表将通过JavaScript动态加载 -->
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">关闭</button>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    <script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script>
    <script src="js/drone-app.js"></script>
</body>
</html>